package com.ellricky.baselib.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.andr.common.ui.dialog.BaseDialog;
import com.ellricky.baselib.R;
import com.ellricky.baselib.listener.OnBackScanListener;
import com.ellricky.baselib.util.GlideUtil;
import com.flyco.roundview.RoundTextView;

import de.hdodenhof.circleimageview.CircleImageView;

public class ScanDialog extends BaseDialog {

    // 学生名称
    private String name;
    // 学生头像
    private String headPic;
    // 签到时间
    private String clickTime;
    // 成功的消息
    private String isSuccessMsg;

    private RoundTextView tvBackScan;

    private OnBackScanListener listener;


    public void setListener(OnBackScanListener listener) {
        this.listener = listener;
    }


    @Override
    public int getCustomLayoutId() {
        return R.layout.dialog_scan;
    }

    public ScanDialog(Context context) {
        super(context);
        setSizeWidth(WindowManager.LayoutParams.MATCH_PARENT);
        setGravity(Gravity.CENTER);
    }


    @Override
    public void initWidgets() {

        CircleImageView ivAvatar = findViewById(R.id.ivAvatar);
        GlideUtil.into(context, headPic, ivAvatar);

        TextView tvName = findViewById(R.id.tvName);
        tvName.setText(name);

        TextView tvMsg = findViewById(R.id.tvMsg);
        tvMsg.setText(isSuccessMsg);

        TextView tvSignDate = findViewById(R.id.tvSignDate);
        tvSignDate.setText(clickTime);

        tvBackScan = findViewById(R.id.btnScan);
        tvBackScan.setOnClickListener(this);

    }


    @Override
    public void onClickView(View v) {
        dismiss();
        if (listener != null) listener.onBackScan();

    }


    public void setInfo(String headPic, String name, String msg, String time) {
        this.headPic = headPic;
        this.isSuccessMsg = msg;
        this.name = name;
        this.clickTime = time;
    }


}
